package com.dmj.sqldsl.executor.visitor;

import com.dmj.sqldsl.executor.SqlDialect;
import com.dmj.sqldsl.executor.exception.UnsupportedSqlDialectException;
import lombok.experimental.UtilityClass;

@UtilityClass
public class ModelVisitorFactory {

  public QueryModelVisitor getQueryModelVisitor(SqlDialect dialect) {
    switch (dialect) {
      case mysql:
      case h2:
        return new QueryModelVisitor();
      case postgresql:
        return new PostgresqlQueryModelVisitor();
      case oracle:
        return new OracleQueryModelVisitor();
      case sqlserver:
        return new SqlserverQueryModelVisitor();
      default:
        throw new UnsupportedSqlDialectException(dialect);
    }
  }

  public DeleteModelVisitor getDeleteModelVisitor(SqlDialect dialect) {
    return new DeleteModelVisitor(getQueryModelVisitor(dialect));
  }

  public UpdateModelVisitor getUpdateModelVisitor(SqlDialect dialect) {
    return new UpdateModelVisitor(getQueryModelVisitor(dialect));
  }
}
